﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using QuickGame.View;

namespace QuickGame.Model
{
    public class CauTraLoiHs
    {
        public static IQueryable<CauTraLoi> QueryEntities(ModelContext modelContext)
        {
            return modelContext.CauTraLois;
        }

        public static CauTraLoi QueryEntity(ModelContext modelContext, long id)
        {
            return modelContext.CauTraLois.Single(k => k.ID == id);
        }
        public static CauTraLoi Insert(ModelContext modelContext)
        {
            CauTraLoi ctl = new CauTraLoi();
            modelContext.CauTraLois.AddObject(ctl);
            return ctl;
        }
        public static void Delete(ModelContext modelContext, long id)
        {
            CauTraLoi ctl = modelContext.CauTraLois.Single(k => k.ID == id);
            modelContext.CauTraLois.DeleteObject(ctl);
        }
        public static void Update(ModelContext modelContext, CauTraLoiView view)
        {
            CauTraLoi ctl = modelContext.CauTraLois.Single(k => k.ID == view.ID);
            //ctl.ID = view.ID;
            ctl.Ma = view.Ma;
            ctl.Ten = view.Ten;
            ctl.TrangThai = view.TrangThai;
            modelContext.SaveChanges();
        }
    }
}